package edu.jvn.ict.locationsharing.informationexchange;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import edu.jvn.ict.locationsharing.MemberInfo;
import edu.jvn.ict.locationsharing.MemberServer;
import edu.jvn.ict.locationsharing.Utility;

public class RequestDictionaryMessage extends ExchangeMessage{

	/**
	 * 
	 */
	public static final int MESSAGE_ID = 6;
	private static final long serialVersionUID = 2273289943815580489L;

	@Override
	public void process(ObjectInputStream in, ObjectOutputStream out) throws IOException {
		out.writeInt(MemberServer.thisMember.getNodeStatus());
		out.flush();
		
		if (MemberServer.thisMember.getNodeStatus() == MemberInfo.ONLINE) {
			out.writeObject(MemberServer.dictionary);
		}
		
	}
	
	public String toString(){
		return Utility.APP_START_MESSAGE + Integer.toString(MESSAGE_ID);
	}
	
	public RequestDictionaryMessage(){
		
	}

}
